﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FrameConstructor;


namespace TetrisShape
{
    public class Render
    {
        private int totalScore = 0;
        public int TotalScore
        {
            get { return totalScore; }
            protected set { totalScore = value; }
        }
        //Print changes on console.
        public void Print(Shape sh, Frame fr, Field fi)
        {
            try
            {
                Console.Clear();
                fi.SetGameField();
                GetTotalScore(fr);
                sh.SetColor();
                foreach (Shape currentShape in sh.returnShape)
                {
                    foreach (Block currentBlock in currentShape.returnBlock)
                    {
                        Console.CursorVisible = false;
                        Console.SetCursorPosition(currentBlock.X, currentBlock.Y);
                        Console.WriteLine("■");
                    }
                }
                sh.SetFieldColor();
                foreach (Shape shape in fi.returnFieldShapeStorage)
                {
                    foreach (Block block in shape.returnBlock)
                    {
                        Console.CursorVisible = false;
                        Console.SetCursorPosition(block.X, block.Y);
                        Console.WriteLine("■");
                    }
                }
            }
            catch
            {
                return;
            }
        }
        //Get current quantity of points.
        public void GetTotalScore(Frame fr)
        {

            GetPoints();
            Console.SetCursorPosition(fr.StartX + 15, fr.StartY);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Total Score : {0}", totalScore);
        }
        //Get quantity of points for current line(s).
        public int GetPoints()
        {
            if (Field.scoreCounter == 1)
                totalScore += 100;
            else if (Field.scoreCounter == 2)
                totalScore += 300;
            else if (Field.scoreCounter == 3)
                totalScore += 500;
            else if (Field.scoreCounter == 4)
                totalScore += 700;

            return totalScore;
        }
    }
}
